package com.bana.sys.service;

import com.bana.sys.code.ValidateResult;
import com.bana.sys.utils.Token;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class LoginService {

    /**
     * 验证token
     * @param token
     * @return 返回true表示验证成功
     */
    public int validateToken(String token)
    {
        long timeStamp=Token.getTimeStamp(token);
        if(timeStamp==0)
        {
            return ValidateResult.Failed;
        }

        Date now=new Date();
        long diff=now.getTime()- timeStamp;
        return diff<60*60*1000?ValidateResult.Success:ValidateResult.Failed;
    }
}
